home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr10 / accent12.zip / ACCENT12.S < prev    next >
Text File  |  1993-06-15  |  5KB  |  159 lines

  1. /**************** Foreign-Character Macros **************************
  2.  
  3.   For TSE (The Semware Editor), pre-release version 1.0
  4.  
  5.   Author:  David Mayerovitch
  6.            macro version 1.0 07 June 1993
  7.            macro version 1.1 12 June 1993
  8.            - added Spanish, more French characters
  9.            - removed International
  10.            macro version 1.2 15 June 1993
  11.            - added Spanish ordinals
  12.  
  13.   This pair of macros provides a quick and convenient way of entering
  14.   foreign-language and other special characters.
  15.  
  16.   mSelectLanguage() presents a menu of languages or other
  17.   special-character sets for the user to choose from. I have assigned
  18.   this macro to <Alt `>.
  19.  
  20.   mAccenter() enables the entry of the special characters belonging to
  21.   the selected set.  I have assigned this macro to the key <`>. Call
  22.   this the trigger key.
  23.  
  24.   These macros do what you do when writing foreign characters by hand:
  25.   first write the basic letterform, then add the diacritical mark.
  26.   Example: If the selected language is French and you want to enter
  27.   the character <é> (e with accent aigu): type the basic character
  28.   <e>, then press the trigger key.  A pop-up menu appears:
  29.  
  30.   ┌──────────┐
  31.   │ Aigu   é │
  32.   │ Grave  è │
  33.   │ Circ   ê │
  34.   │ Umlaut ë │
  35.   └──────────┘
  36.  
  37.   The hotkeys A, G, C, and U generate the four possible e-based
  38.   accented characters in French. Press <A> and the <e> just
  39.   typed will be replaced with <é>.
  40.  
  41.   When there is only one possible accented version of the character
  42.   just typed (e.g. ü in German), the macro automatically inserts it
  43.   without popping up a menu.
  44.  
  45.   The macros as presented here offer the following character sets:
  46.   French: à â ç Ç é è ê ë É î ï ô ù û
  47.   German: ä Ä ö ü Ü
  48.   Spanish: á é í ó ú ñ Ñ ¿ ¡
  49.   Currency: c/C --> ¢ (cents)  l/L --> £ (pounds)  y/Y --> ¥ (yen)
  50.  
  51.   French is the default: it is automatically selected when the macro
  52.   is loaded.  Change the default by changing the global variable
  53.   Language (see macro source below).
  54.  
  55.   You may easily edit the macros to provide any substitutions you
  56.   want.  Strings as well as single characters may be substituted: the
  57.   string "integer" could be expanded from "i", or your name from your
  58.   initial.  Modify the language menu to provide character sets of your
  59.   choice - math, Greek, graphics, and so on.
  60.  
  61.   If you have occasional need for characters from different languages,
  62.   you might group them into a single International set rather than
  63.   switching languages.  The tradeoff would be that you'd have fewer
  64.   automatic substitutions and more menu choices.
  65.  
  66.   If a printable key such as <`> is chosen as the trigger for
  67.   mAccenter(), the Literal() command (assigned to <Ctrl P> in the
  68.   factory configuration of TSE) may be used whenever the character
  69.   itself is required in the text.
  70.  
  71.   Comments and improvements are welcome.
  72.  
  73. ********************************************************************/
  74.  
  75. // global variable:
  76. integer language = 1 // French is default
  77. // make it 3 and you have Spanish default
  78.  
  79. // LANGUAGE SELECTION ROUTINES:
  80.  
  81. menu langMenu()
  82.   history
  83.   "&French"  "&German"   "&Spanish"
  84.   "", , Divide  "&Currency"
  85. end
  86. proc mSelectLanguage()
  87.   langMenu()  language = MenuOption()
  88. end
  89.  
  90. // CHARACTER SUBSTITUTION ROUTINES:
  91.  
  92. proc sub(string newstring)
  93. // replaces current char by newstring, forcing insert.
  94.   DelChar()  InsertText(newstring,_insert_)
  95. end
  96.  
  97. menu FrenchAMenu()
  98.   "&Grave à", sub('à') "&Circ  â", sub('â')
  99. end
  100. menu FrenchEMenu()
  101.   "&Aigu   é", sub('é') "&Grave  è", sub('è') "&Circ   ê", sub('ê')
  102.   "&Umlaut ë", sub('ë')
  103.   end
  104. menu FrenchIMenu()
  105.   "&Circ   î", sub('î') "&Umlaut ï", sub('ï')
  106.   end
  107. menu FrenchUMenu()
  108.   "&Grave  ù" , sub('ù') "&Circ   û", sub('û')
  109. end
  110. menu SpanishOMenu()
  111.   "&Accent  ó", sub('ó')  "&Ordinal º", sub('º')
  112. end
  113. menu SpanishAMenu()
  114.   "&Accent  á", sub('á')  "&Ordinal ª", sub('ª')
  115. end
  116.  
  117. proc French()
  118.   case Chr(CurrChar())
  119.     when 'a' FrenchAMenu() when 'e' FrenchEMenu()
  120.     when 'i' FrenchIMenu() when 'u' FrenchUMenu()
  121.     when 'E' sub('É') when 'c' sub('ç') when 'C' sub('Ç')
  122.     when 'i' sub('î') when 'o' sub('ô')
  123.     otherwise Right() endcase
  124. end
  125. proc German()
  126.   case Chr(CurrChar())
  127.     when 'a' sub('ä') when 'A' sub('Ä') when 'o' sub('ö')
  128.     when 'O' sub('Ö') when 'u' sub('ü') when 'U' sub('Ü')
  129.     otherwise Right() endcase
  130. end
  131. proc Spanish()
  132.   case Chr(CurrChar())
  133.     when 'a' SpanishAMenu() when 'o' SpanishOMenu()
  134.     when 'e' sub('é') when 'i' sub('í')
  135.     when 'o'  when 'u' sub('ú') when 'n' sub('ñ')
  136.     when 'N' sub('Ñ')
  137.     when '?' sub('¿') when '/' sub('¿') // unshifted ? key
  138.     when '!' sub('¡') when '1' sub('¡') // unshifted ! key
  139.     otherwise Right() endcase
  140. end
  141. proc Currency()
  142.   case UpCase(Chr(CurrChar()))
  143.     when 'C' sub('¢') // cents
  144.     when 'L' sub('£') // pounds
  145.     when 'Y' sub('¥') // yen
  146.     otherwise Right() endcase
  147. end
  148.  
  149. proc mAccenter()
  150.   Left()
  151.   Case language
  152.     when 1 French() when 2 German() when 3 Spanish()
  153.     when 5 Currency()
  154.     endcase
  155. end
  156. <`> mAccenter()
  157. <Alt `> mSelectLanguage()
  158. /************************** End of macros **************************/
  159.